import { defineStore } from "../ pinia/index";
import { ref } from "vue";
// export const useStoreIndex = defineStore("storeId", {
//   state: () => {
//     return {
//       name: "123",
//       age: 40,
//     };
//   },
//   getters: {
//     getAge: (state) => {
//       return state.age;
//     },
//     doubleAge: (state) => {
//       return state.age * 2;
//     },
//   },

//   actions: {
//     increment(num) {
//       return this.age + 2;
//     },
//   },
// });

export const useStoreIndex = defineStore("storeId", () => {
  const age = ref(23);
  const name = "莞尔一笑";
  function getAge() {
    return age;
  }
  function increment() {
    return age.value + 2;
  }
  const changeAge = (val) => {
    age.value = val;
    return age.value;
  };
  return {
    age,
    name,
    getAge,
    changeAge,
    increment,
  };
});
